package io.gitee.hechenl.easyopc.controller;

import cn.hutool.json.JSONUtil;
import io.gitee.hechenl.easyopc.service.ICacheService;
import io.gitee.hechenl.easyopc.service.IOpcUaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/opcua")
public class OpcUaTestController {

    @Autowired
    private ICacheService cacheService;
    @Autowired
    private IOpcUaService opcUaService;


    @GetMapping("/allData")
    public String allData() {
        Map<String, String> all = cacheService.getAll();
        return JSONUtil.toJsonStr(all);
    }

    @GetMapping("/{id}")
    public String read(@PathVariable("id") String id) {
        return opcUaService.read(id);
    }

}
